package threading;
//线程中断..自创标志位
public class demo3 {
    static boolean isQuit = false;
    public static void main(String[] args){
        Thread t = new Thread(()->{
            while(!isQuit){
                System.out.println("hello thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程执行完了。");
        });
        t.start();

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        isQuit = true;
        System.out.println("设置让t线程结束");
    }
}
